export const fetchAudio = async (text) => {
    try {
        const response = await fetch(`${process.env.REACT_APP_API_URL}/generate_audio`, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
            },
            body: JSON.stringify(text),
        });
        if (!response.ok) throw new Error("Failed to fetch audio");

        const blob = await response.blob();
        return URL.createObjectURL(blob); // 返回音频 URL
    } catch (error) {
        console.error("Error fetching audio:", error);
        return null;
    }
};